﻿#region File Info Header
/*________________________________________________________________________________________

  Copyright (C) 2011 Jason Zhang, eagleboost@msn.com

  * THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, 
  * EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED 
  * WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE.

________________________________________________________________________________________*/
#endregion File Info Header

namespace EagleBoost.Wpf.Presentation.Converters
{
  using System.Windows.Data;
  using System.Windows.Markup;

  /// <summary>
  /// Base class for converters can be used as a MarkupExtension
  /// </summary>
  /// <typeparam name="T"></typeparam>
  [MarkupExtensionReturnType(typeof(IValueConverter))]
  public class ConverterMarkupExtension<T> : MarkupExtension where T : class, IValueConverter, new()
  {
    #region ctors
    static ConverterMarkupExtension()
    {
      Instance = new T();
    }
    #endregion ctors

    #region Private Properties
    private static T Instance { get; set; }
    #endregion Private Properties

    #region Overrides
    public override object ProvideValue(System.IServiceProvider serviceProvider)
    {
      return Instance;
    }
    #endregion Overrides
  }
}
